Attempt to plaster over note->description grief when wpt is added.
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Mon, 9 Dec 2002 06:00:26 +0000 (06:00 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Mon, 9 Dec 2002 06:00:26 +0000 (06:00 +0000)
Add option to CSV to prefer shortname over description.

gpsbabel/csv.c
gpsbabel/waypt.c

index b2141d9c39ed06228ab8c57646e51fd70043e07f..3d6922fdecfbaedb8a476a29fb59d1f5643a3fcc 100644 (file)
@@ -26,6 +26,7 @@
 
 static FILE *file_in;
 static FILE *file_out;
+static char *psn;
 
 #define MYNAME "CSV"
 
@@ -48,6 +49,8 @@ static void
 wr_init(const char *fname, const char *args)
 {
        file_out = fopen(fname, "w");
+       psn = get_option(args, "prefer_shortname");
+
        if (file_out == NULL) {
                fatal(MYNAME ": Cannot open %s for writing\n", fname);
        }
@@ -143,8 +146,13 @@ csv_waypt_pr(const waypoint *wpt)
        lon = wpt->position.longitude.degrees;
        lat = wpt->position.latitude.degrees;
 
-        if (wpt->description) 
-           description = csv_stringclean(wpt->description, ",\"");
+       if (psn)  {
+               if (wpt->shortname) 
+                   description = csv_stringclean(wpt->shortname, ",\"");
+       } else {
+               if (wpt->description) 
+                   description = csv_stringclean(wpt->description, ",\"");
+       }
 
        if ((description == NULL) && wpt->notes)
            description = csv_stringclean(wpt->notes, ",\"");
index 6aea8a5280c9de1cb32abc4ff732fdad7ce86843..761d17bd2f10fb1c37ca4e04c31956661d50b817 100644 (file)
@@ -35,6 +35,11 @@ void
 waypt_add(waypoint *wpt)
 {
        ENQUEUE_TAIL(&waypt_head, &wpt->Q);
+       if (wpt->description == NULL) {
+               if (wpt->notes != NULL) {
+                       wpt->description = xstrdup(wpt->notes);
+               }
+       }
        waypt_ct++;
 }